package chapter01

object Test04_input {
  def main(args: Array[String]): Unit = {
    //读取控制台数据
    val i: Int = scala.io.StdIn.readInt()
    println(i)
    val str: String = scala.io.StdIn.readLine()
    println(str)
    //读取文件
    val text = scala.io.Source.fromFile("text.txt")
    println(text)
    //循环输出
    text.foreach(line=>print(line))
    //按行读取
    val lines = scala.io.Source.fromFile("text.txt").getLines()
    lines.foreach(line=>println(line))
  }
}
